package sky.valve;

import org.apache.catalina.Valve;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.valves.ValveBase;
import org.apache.coyote.http11.Constants;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @author : wushikai
 * <p>
 * date : 2022-05-16
 */
public class LogValve extends ValveBase {


    private static final Log log = LogFactory.getLog(StandardContext.class);




    @Override
    public void invoke(Request request, Response response) throws IOException, ServletException {


        log.warn("url==>"  +   request.getRequestURI()  + Constants.CRLF   + request.toString());
        Valve valve = getNext();
        while (valve != null){

            System.out.println("valve.getClass().getCanonicalName() = " + valve.getClass().getCanonicalName());
            valve =valve.getNext();

        }

    }
}
